let coins = [3,7,405,436]
let amount = 8839
let result = []

// 初始化 dp 数组，长度为 amount + 1，初始值为 Infinity
const dp = new Array(amount + 1).fill(Infinity);
dp[0] = 0; // 凑成金额 0 的硬币数为 0

for(let i = 1; i <= amount; i++){
    for (let coin of coins){
        if (i - coin >= 0) { // 确保 i - coin 是有效的金额
            dp[i] = Math.min(dp[i], dp[i - coin] + 1);
        }
    }
}
console.log(dp[amount]);
// 如果 dp[amount] 仍然是 Infinity，说明无法凑成总金额
return dp[amount] === Infinity ? -1 : dp[amount];